<?php
session_cache_expire(999999999);
if(!isset($_SESSION)) 
	{ 
		session_start(); 
	}
    //$DBhost = '1.234.53.52';
  //	$DBuser = 'cam';
   //	$DBpass = '5678';
   //	$DBName = 'elihan';
 //   $DBName = 'dbbackup';

if(!isset($_SESSION['db'])){
	$addressbrowser = $_SERVER['SERVER_NAME'];
	$temp = explode(".", $addressbrowser);
	$connection = mysql_connect("1.234.53.52", "cam", "5678" ) ;
	//$connection = mysql_connect("localhost", "root", "root" ) ;
	mysql_select_db("elihan", $connection);
	mysql_query("set names 'utf8'");
	$selectdatabase = mysql_query("SELECT am.DatabaseName,am.Logo from ac_eli_manager am where am.KeyName='$temp[0]'  and am.`Status` = 2");
	$result = mysql_fetch_assoc($selectdatabase);

	$_SESSION['Logo']=$result[Logo];
	$_SESSION['db']= $result[DatabaseName];
	mysql_close($connection);
}
$database = $_SESSION['db'];

	try {
		ini_set('display_errors', 0);
		$connection = mysql_connect("1.234.53.52", "cam", "5678" ) ;
		//$connection = mysql_connect("localhost", "root", "root" ) ;
		if(!$connection){		
			session_destroy();	
			include 'backlogin.php';	
		}		
		if(!mysql_select_db($database,$connection)){	
			echo $database;	
			session_destroy();	
			include 'backlogin.php';	
		}
		if(!mysql_query("SET CHARACTER SET 'utf8'", $connection)){		
			session_destroy();	
			include 'backlogin.php';	
		}
	} catch (Exception $e) {
		session_destroy();
		include 'backlogin.php';	
		
	}
		
?>